package remoting.grpc;

import common.exception.RemotingException;
import common.factory.Factory;
import common.factory.MagicFactory;
import common.model.MagicUrl;
import remoting.Client;
import remoting.Server;
import remoting.Transporter;
import remoting.channel.ChannelHandler;

public class GrpcTransporter implements Transporter {
  public static final String NAME = "grpc";

  @Override
  public Server bind(MagicUrl url, ChannelHandler listener) throws RemotingException {
    return new GrpcServer(url, listener, MagicFactory.getMagicFactory().getThreadPool(), MagicFactory.getMagicFactory().getCodec2());
  }

  @Override
  public Client connect(MagicUrl url, ChannelHandler listener) throws RemotingException {
    return new GrpcClient(url, listener, MagicFactory.getMagicFactory().getCodec2());
  }
}
